/*
package cn.xx.basic.service.impl;

import cn.xx.basic.constant.VerifactionCodeConstant;
import cn.xx.basic.exception.CustomException;
import cn.xx.basic.util.SendMsgUtil;
import cn.xx.basic.util.StrUtils;
import cn.xx.basic.service.IVerfactionService2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.concurrent.TimeUnit;

@Service
public class VerfactionServiceImpl2 implements IVerfactionService2 {

    @Autowired
    private RedisTemplate redisTemplate;



    */
/*
    * 根据手机号生成验证码
    * *//*

    @Override
    public void sendMobileCode(String phone) throws CustomException {
        System.err.println(phone);
        //产生随机验证码
        String code = StrUtils.getComplexRandomString(4);
        //通过key值，在redis中查找验证码是否存在
        String codeValue = (String) redisTemplate.opsForValue().get(phone + ":" + VerifactionCodeConstant.REG_CODE);
        //如果codeValue存在，就证明验证码还没有过期
        if(!StringUtils.isEmpty(codeValue)){
            String beginTimer = codeValue.split(":")[1];
            //结束毫秒时间-开始毫秒时间
            if((System.currentTimeMillis()-Long.valueOf(beginTimer))<60*1000){
                throw new CustomException("一分钟以内不能发送多次验证码!!");
            }
            //超过了1分钟，但依然在5分钟以内
            code = codeValue.split(":")[0];
        }
        //产生的验证码放到redis里面
        redisTemplate.opsForValue().set(phone+":"+ VerifactionCodeConstant.REG_CODE, code+":"+System.currentTimeMillis(),
                5, TimeUnit.MINUTES);
        String content = "尊敬的来宾,您的验证码为:" + code + ",请在5分钟以内完成验证操作!!";
        System.out.println(content);

        //发送短信
        SendMsgUtil.sendMsg(phone, content);

    }
}
*/
